package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/6.
 */
@HttpInlet(Conn.SEARCH_HOT)
public class SearchHotGet extends BaseAsyGet<SearchHotGet.SearchHotListEntity> {

    public SearchHotGet(AsyCallBack<SearchHotListEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected SearchHotListEntity parser(JSONObject object) throws Exception {

        if(object.optInt("code")==200){

            SearchHotListEntity searchHotListEntity = new SearchHotListEntity();

            JSONArray jsonArray = object.optJSONArray("data");

            for(int i=0;i<jsonArray.length();i++){

                searchHotListEntity.data.add(jsonArray.optString(i));

            }

            return searchHotListEntity;

        }

        TOAST = object.optString("message");

        return null;
    }

    public static class SearchHotListEntity{

        public List<String> data = new ArrayList<>();

    }

}
